package dto

import (
	"tuowei.com/app/admin/models"
	"tuowei.com/common/dto"
	common "tuowei.com/common/models"
)

type SysExercisesGetPageReq struct {
	dto.Pagination `search:"-"`
	Name           string `form:"name" search:"type:contains;column:name;table:sys_exercises" comment:"名称"`      // 名称
	Status         int    `form:"status" search:"type:exact;column:status;table:sys_exercises" comment:"状态"`     // 状态
	Subject        string `form:"subject" search:"type:exact;column:subject;table:sys_exercises" comment:"科目筛选"` // 状态
}

func (m *SysExercisesGetPageReq) GetNeedSearch() interface{} {
	return *m
}

type SysExercisesInsertReq struct {
	Id   int    `json:"id" comment:"主键ID"`
	Name string `json:"name" comment:"练习题名称" vd:"@:len($)>0; msg:'练习题名称不能为空'"`
	//Type         string `json:"type" comment:"类型" vd:"@:len($)>0; msg:'请选择类型'"`
	Subject      string `json:"subject" comment:"科目" vd:"@:len($)>0; msg:'请选择科目'"`
	Cover        string `json:"cover" comment:"练习题封面" vd:"@:len($)>0; msg:'请上传封面'"`
	Description  string `json:"description" comment:"描述"`
	PublicRange  string `json:"public_range" comment:"公开范围"`
	PublishRange string `json:"publish_range" comment:"发布范围" vd:"@:len($)>0; msg:'请选择发布范围'"`
	Status       int    `json:"status" gorm:"size:1;column:status"`
	common.ControlBy
}

func (s *SysExercisesInsertReq) GetId() interface{} {
	return s.Id
}

func (s *SysExercisesInsertReq) Generate(model *models.SysExercises) {
	//model.CourseId = s.CourseId
	model.Name = s.Name
	//model.Type = s.Type
	model.Description = s.Description
	model.Subject = s.Subject
	model.Cover = s.Cover
	model.PublishRange = s.PublishRange
	model.PublicRange = s.PublicRange
	model.Status = s.Status
	model.CreateBy = s.CreateBy
	model.Creator = s.Creator
}

type SysExercisesUpdateReq struct {
	Id   int    `json:"id" comment:"主键ID" vd:"$>0;msg:'更新ID不能为空'"`
	Name string `json:"name" comment:"练习题名称" vd:"@:len($)>0; msg:'练习题名称不能为空'"`
	//Type         string `json:"type" comment:"类型" vd:"@:len($)>0; msg:'请选择类型'"`
	Cover        string `json:"cover" comment:"练习题封面" vd:"@:len($)>0; msg:'请上传封面'"`
	Subject      string `json:"subject" comment:"科目" vd:"@:len($)>0; msg:'请选择科目'"`
	Description  string `json:"description" comment:"描述"`
	PublicRange  string `json:"public_range" comment:"公开范围"`
	PublishRange string `json:"publish_range" comment:"发布范围" vd:"@:len($)>0; msg:'请选择发布范围'"`
	Status       int    `json:"status" gorm:"size:1;column:status"`
	common.ControlBy
}

func (s *SysExercisesUpdateReq) Generate(model *models.SysExercises) {
	//model.CourseId = s.CourseId
	if s.Id != 0 {
		model.Id = s.Id
	}
	model.Name = s.Name
	//model.Type = s.Type
	model.Subject = s.Subject
	model.Cover = s.Cover
	model.Description = s.Description
	model.PublishRange = s.PublishRange
	model.PublicRange = s.PublicRange
	model.Status = s.Status
	model.UpdateBy = s.UpdateBy
	model.Updater = s.Updater
}

func (s *SysExercisesUpdateReq) GetId() interface{} {
	return s.Id
}

type SysExercisesById struct {
	dto.ObjectById
	common.ControlBy
}

type SaveChapterSubmitReq struct {
	ObjId     int `json:"obj_id" vd:"$>0; msg:'关联ID不能为空 link_type = 1时 obj_id传入 网课的主键ID（course_id）;link_type = 2时 obj_id传入 练习题的主键ID（id）;link_type = 3时 obj_id传入 试卷的主键ID（id）'"`
	LinkType  int `json:"link_type" comment:"1-网课类型 2-题库练习题类型 3-试卷类型" vd:"$>0; msg:'1-网课类型 2-练习题类型 3-试卷类型'"`
	ChapterId int `json:"chapter_id" comment:"子章节ID"`
}
